{* $Id$ *}
{include_core file="admin/lib/header.html" title="影院简报"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">影院月简报</h2>
    <a style="margin-top:5px; display:block; float:right;" href="{get_url()}&is_excel=1" class="btn btn-xs btn-primary js_downList">导出筛选EXCEL</a>
    <a style="margin-top:5px; display:block; float:right;" href="{AnUrl("cinema/admin/cinema_brief/combine_export?province_combine=1&month={$search_filter['month']}&is_excel=1")}" class="btn btn-xs btn-primary js_downList">导出所有省合并数据</a>
    <a style="margin-top:5px; display:block; float:right;" href="{AnUrl("cinema/admin/cinema_brief/combine_export?city_combine=1&month={$search_filter['month']}&is_excel=1")}" class="btn btn-xs btn-primary js_downList">导出所有城市合并数据</a>
</div>
<div class="search-form js_advancedForm">
    <form action="{AnUrl("cinema/admin/cinema_brief/brief")}" method="get" class="js_focusSearchForm">
        <p>
            <label for="" class="search-f-label">影院名称：</label>
            <input type="text" class="search-f-ipt1" name="search_filter[title]" value="{$search_filter.title}">
        </p>
        <p style="height: auto;">
            <label class="search-f-label">选择省份：</label>
            {foreach $provinceList as $k => $v}
            <label class="label label-default"><input value="{$k}" name="search_filter[province_id][]" {if isset($search_filter['province_id']) && in_array($k, $search_filter['province_id'])}checked="checked"{/if} type="checkbox">{$v}</label>&nbsp;&nbsp;
            {/foreach}
        </p>
        <p>
            <label for="" class="search-f-label">月份筛选：</label>
            <select name="search_filter[month]" style="width:120px;">
                {foreach $monthList as $k=>$v}
                <option value="{$v}" {if $v == $search_filter['month']}selected="selected"{/if}>{$v}</option>
                {/foreach}
            </select>
        </p>
        <p>
            <label for="" class="search-f-label">院线：</label>
            <select name="search_filter[circuit]" style="width:120px;">
                <option value="0">全部</option>
                {foreach $circuit as $k=>$v}
                <option value="{$v['name']}" {if $search_filter['circuit'] == $v['name']}selected="selected"{/if}>{$v['name']}</option>
                {/foreach}
            </select>
        </p>
        <p>
            <label for="" class="search-f-label">影投公司：</label>
            <select name="search_filter[investment_company]" style="width:120px;">
                <option value="0">全部</option>
                {foreach $investment_company as $k=>$v}
                <option value="{$v['name']}" {if $search_filter['investment_company'] == $v['name']}selected="selected"{/if}>{$v['name']}</option>
                {/foreach}
            </select>
        </p>
        <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">确定</button></p>
    </form>
</div>

<h1 style="margin-top: 25px;line-height: 2em;font-size: 1.4em;background: #eee;border-top:1px solid #ddd">省/月筛选订单总金额(不包含院线\影投公司筛选条件)</h1>
<section id="month_map" style="height: 600px;margin: 20px 0 0 0;"></section>
<table class="list-table">
    <thead>
    <tr>
        <th>排序</th>
        <th>1</th>
        <th>2</th>
        <th>3</th>
        <th>4</th>
        <th>5</th>
        <th>6</th>
        <th>7</th>
        <th>8</th>
        <th>9</th>
        <th>10</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>{$search_filter['month']} 订单Top10的省份</td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
        <td class="top10province"></td>
    </tr>
    <tr>
        <td>{$search_filter['month']} 订单Top10的城市</td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
        <td class="top10city"></td>
    </tr>
    </tbody>
</table>

<h1 style="margin-top: 20px;line-height: 2em;font-size: 1.4em;background: #eee;border-top:1px solid #ddd">筛选结果</h1>
<section style="height:auto;line-height:auto;margin-top: 10px;">
    <p>
        专资办:
        <a href='{get_url()}&include_zzb_code=-1' {if $include_zzb_code < 0} class="label label-primary" {else} class="label label-default" {/if}>全部</a>
        <a href='{get_url()}&include_zzb_code=1' {if $include_zzb_code > 0} class="label label-primary" {else} class="label label-default" {/if}>有专资办编码</a>
        <a href='{get_url()}&include_zzb_code=0' {if $include_zzb_code == 0} class="label label-primary" {else} class="label label-default" {/if}>无专资办编码</a>
    </p>
    <p>
        排序：
        <a href='{get_url()}&order_type=-1' {if $order_type <= 0} class="label label-primary" {else} class="label label-default" {/if}>全部</a>
        <a href='{get_url()}&order_type=1' {if $order_type == 1} class="label label-primary" {else} class="label label-default" {/if}>票房</a>
        <a href='{get_url()}&order_type=2' {if $order_type == 2} class="label label-primary" {else} class="label label-default" {/if}>观影人次</a>
        <a href='{get_url()}&order_type=3' {if $order_type == 3} class="label label-primary" {else} class="label label-default" {/if}>进货金额</a>
        <a href='{get_url()}&order_type=4' {if $order_type == 4} class="label label-primary" {else} class="label label-default" {/if}>SPP</a>
    </p>
</section>

<table class="list-table">
    <thead>
        <tr>
            <th>{$search_filter['month']}<br>订单总金额</th>
            <th>{$search_filter['month']}<br>影院总数</th>
            <th>{$search_filter['month']}<br>下单影院数</th>
            <th>{$search_filter['month']}<br>订单总笔数</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>{$cinema_month_money_sum}</td>
            <td>{$cinema_month_total}</td>
            <td>{$cinema_month_had_order_count}</td>
            <td>{$cinema_month_order_count_sum}</td>
        </tr>
    </tbody>
</table>
<div style="height: 10px;"></div>
<!--start:列表-->
<table class="list-table">
    <thead><tr>
        <th>序号</th>
        <th>后台id</th>
        <th>专资编码</th>
        <th style="min-width: 100px;">影院名称</th>
        <th style="min-width: 70px;">签约时间</th>
        <th style="min-width: 50px;">类型</th>
        <th style="min-width: 50px;">省市区</th>
        <th>{$search_filter['month']}<br>票房/元</th>
        <th>{$search_filter['month']}<br>观影人次</th>
        <th>{$search_filter['month']}<br>进货金额</th>
        <th>{$search_filter['month']}<br>SPP</th>
        <th>操作</th>
    </tr></thead>
    <tbody>
    {foreach $store_list as $k=>$v}
    <tr {if $k%2 == 1} class="bg-gray"{/if}>
    <td>{$k+1}</td>
    <td>{$v.id}</td>
    <td>{$v.zzb_id}</td>
    <td data_id="{$v.id}">{$v.cinema_name}</td>
    <td>{time_format($v.add_time)}</td>
    <td>{if $v.type_name == 100}电影院{else}私人影吧{/if}</td>
    <td>{$v.province}<br>{$v.city}<br>{$v.county}</td>
    <td>{$v.box_office}</td>
    <td>{$v.viewers}</td>
    <td>{$v.order_money}</td>
    <td>{if $v.spp != -1}
        {if $v.spp <= 0.3}
                  <span class="label label-danger">
                  {/if}
                  {if $v.spp <= 0.4 && $v.spp > 0.3}
                  <span class="label label-warning">
                  {/if}
                  {if $v.spp <= 0.6 && $v.spp > 0.4}
                  <span class="label label-success">
                  {/if}
                  {if $v.spp > 0.6}
                  <span class="label label-primary">
                  {/if}
                  {$v.spp}</span>
              {/if}
    </td>
    <td>
        <a href="{AnUrl("cinema/admin/cinema_manage/show?id={$v.id}")}" class="btn btn-success btn-xs"><i class="icon-trash icon-white"></i>查看详情</a>
    </td>
    </tr>
    {foreachelse}
    <tr><td class="txtleft" colspan="15">暂无数据</td></tr>
    {/foreach}
    </tbody>
</table>
<div class="float-bg" style="z-index: 19999; display: none"></div>
{include_core file="admin/lib/pager.html"}

<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{load_js file='echarts/echarts.min.js'}
<script type="text/javascript">
    $(function () {
        var temp = '<div class="linkpop list_detail_pop" style="display: none;">\
                <div class="inner-linkpop" style="padding:8px;max-width:inherit;">\
                <span>\
                <i class="arrowpop"></i>\
                <b class="arrowpop2"></b>\
                </span>\
                <p class="options-list">\
                <table class="list-table">\
                <caption style="height:auto;line-height:auto;">影院名称</caption>\
                <thead>\
                <tr>\
                <th>院线</th>\
                <th>影投公司</th>\
                <th>最后进货时间</th>\
                <th>本月进货金额</th>\
                <th>影院专员</th>\
                <th>合伙人</th>\
                <th>影院负责人</th>\
                <th>累计进货金额</th>\
                </tr>\
                </thead>\
                <tbody>\
                <tr>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                </tr>\
                </tbody>\
                </table>\
                </p>\
                </div>\
                </div>'
        $(document.body).append($(temp));

        var data_id = 0;
        var layerDetail = $('.list_detail_pop');
        var layerDetailContent = $('.list_detail_pop table tbody td');



        $(document.body).on('mouseover', function(e){
            var tar = e.target;
            while (true){
                if (tar.nodeName == 'TD' && $(tar).attr('data_id')) {
                    break;
                }
                if (tar.nodeName == "BODY"){
                    layerDetail.hide();
                    return;
                }
                tar = tar.parentNode;
            }

            var new_data_id = $(tar).attr('data_id');
            if (new_data_id){
                if(data_id == new_data_id){
                    return;
                }
            } else {
                layerDetail.hide();
            }

            data_id = new_data_id;

            if(!data_id){
                return;
            }

            $.ajax({
                        url : '{AnUrl("cinema/admin/cinema_brief/detail?id=")}' + data_id,
                        type : 'get',
                        dataType : 'json',
                        success : function(cinema_detail) {
                            if(cinema_detail.flag == 1){
                                layerDetailContent[0].innerHTML = cinema_detail.message.circuit;
                                layerDetailContent[1].innerHTML = cinema_detail.message.investment_company;
                                layerDetailContent[2].innerHTML = cinema_detail.message.last_order_time;
                                layerDetailContent[3].innerHTML = cinema_detail.message.new_month_cinema_order_money;
                                layerDetailContent[4].innerHTML = cinema_detail.message.cinema_assistant.join('<br>');
                                layerDetailContent[5].innerHTML = cinema_detail.message.agency;
                                layerDetailContent[6].innerHTML = cinema_detail.message.owner;
                                layerDetailContent[7].innerHTML = cinema_detail.message.all_order_money;

                                var position = $(tar).position();

                                layerDetail.css('top', position.top + 110);
                                layerDetail.css('left', position.left + 20);

                                layerDetail.show();
                            }
                        }
                    }
            );
        });

        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('month_map'));
        // 指定图表的配置项和数据
        var option = {
            title: {
                text: ''
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data:[]
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: []
            },
            yAxis: {
                type: 'value'
            },
            series: []
        };
        $.ajax({
            url : '{AnUrl("cinema/admin/cinema_brief/chart?province_ids=")}'+'{join(',',$search_filter['province_id'])}' + "&month=" + '{$search_filter['month']}',
            type : 'get',
            dataType : 'json',
        {literal}
        success : function(cinema_money) {
            if(cinema_money.flag == 1){
                option.xAxis.data = cinema_money.message.recent_years;
                option.legend.data = cinema_money.message.line_name;
                var money_list = cinema_money.message.money_list;
                for(var i = 0; i < money_list.length; i++){
                    option.series.push({
                        name:cinema_money.message.line_name[i],
                        type:'line',
                        stack: '总计',
                        label: {
                            normal: {
                                show: true,
                                position: 'top'
                            }
                        },
                        data:money_list[i]
                    });
                }

                //写入top10
                var top10province = $('.top10province');
                var top10city = $('.top10city');

                var provinceCount = (cinema_money.message.top_province.length > 10)?10:cinema_money.message.top_province.length;
                var cityCount = (cinema_money.message.top_city.length > 10)?10:cinema_money.message.top_city.length;

                for(var i=0; i<provinceCount; i++){
                    top10province[i].innerHTML = cinema_money.message.top_province[i];
                }
                for(var i=0; i<cityCount; i++){
                    top10city[i].innerHTML = cinema_money.message.top_city[i];
                }

                setTimeout(function(){
                    myChart.setOption(option);
                }, 1000);
            }
        }
    }
        {/literal}
        );
    });
</script>
{include_core file="admin/lib/footer.html"}